<?php
session_start();
include('lib/lib.php');
include('connado.php');
//include('authen.php');
header("Content-type: text/html; charset=utf-8");
$logfile = PAHTLOG."ajax_getexch-" . date("Y-m-d") . ".log";

$province_id = $_REQUEST['province_id'];


writelog($logfile, "province_id     : " . $province_id);

$sql = "SELECT e.location_id, e.exch_name, e.exch_addr, e.province_id FROM exchange AS e WHERE e.province_id = ? order by location_id";
$stmt = $db->Prepare($sql);
$arr_pre = array($province_id);
$rs = $db->Execute($stmt, $arr_pre);
$html = '';

while($arr1 = $rs->FetchRow()){
	$html .='<tr>';
	if($arr1){
		$html .='<td width="25%" align="rigth" class="line_dash" ><input type="checkbox" name="location" value="'.$arr1['location_id'].'"/><span class="txt_module">'.$arr1['location_id'].'</span></td>';
	}else{
		$html .='<td width="25%" align="rigth" class="line_dash" >&nbsp;</td>';
	}
	if($arr2 = $rs->FetchRow()){
		$html .='<td width="25%" align="rigth" class="line_dash" ><input type="checkbox" name="location" value="'.$arr2['location_id'].'"/><span class="txt_module">'.$arr2['location_id'].'</span></td>';
	}else{
		$html .='<td width="25%" align="rigth" class="line_dash" >&nbsp;</td>';
	}
	if($arr3 = $rs->FetchRow()){
		$html .='<td width="25%" align="rigth" class="line_dash" ><input type="checkbox" name="location" value="'.$arr3['location_id'].'"/><span class="txt_module">'.$arr3['location_id'].'</span></td>';
	}else{
		$html .='<td width="25%" align="rigth" class="line_dash" >&nbsp;</td>';
	}
	if($arr4 = $rs->FetchRow()){
		$html .='<td width="25%" align="rigth" class="line_dash" ><input type="checkbox" name="location" value="'.$arr4['location_id'].'"/><span class="txt_module">'.$arr4['location_id'].'</span></td>';		
	}else{
		$html .='<td width="25%" align="rigth" class="line_dash" >&nbsp;</td>';
	}
	$html .='</tr>';	
}
$rs->close();
writelog($logfile, "reply : $html");
writelog($logfile, "-------------------------------------------------- ");

echo $html;
?>

